package com.lighthouse.common.tag.service.impl;

import com.lighthouse.common.tag.domain.KnowledgeTag;
import com.lighthouse.common.tag.domain.KnowledgeTagTree;
import com.lighthouse.common.tag.mapper.KnowledgeTagMapper;
import com.lighthouse.common.tag.service.IKnowledgeTagService;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 基础标签Service业务层处理
 * 
 * @author ysz
 * @date 2023-03-22
 */
@Service
public class KnowledgeTagServiceImpl implements IKnowledgeTagService
{
    @Autowired
    private KnowledgeTagMapper knowledgeTagMapper;

    /**
     * 查询基础标签
     * 
     * @param tagId 基础标签主键
     * @return 基础标签
     */
    @Override
    public KnowledgeTag selectBaseTagByTagId(Long tagId)
    {
        return knowledgeTagMapper.selectBaseTagByTagId(tagId);
    }

    /**
     * 查询基础标签列表
     * 
     * @param baseTag 基础标签
     * @return 基础标签
     */
    @Override
    public List<KnowledgeTag> selectBaseTagList(KnowledgeTag baseTag)
    {
        return knowledgeTagMapper.selectBaseTagList(baseTag);
    }

    /**
     * 查询基础标签列表-树形
     *
     * @return 基础标签集合
     */
    @Override
    public List<KnowledgeTagTree> selectBaseTagTree() {
        return knowledgeTagMapper.selectBaseTagTree();
    }

    /**
     * 新增基础标签
     * 
     * @param baseTag 基础标签
     * @return 结果
     */
    @Override
    public int insertBaseTag(KnowledgeTag baseTag)
    {
        baseTag.setCreateTime(DateUtils.getNowDate());
        baseTag.setCreateBy(SecurityUtils.getUsername());
        // 用户自己新增的标签
        baseTag.setIsDiy("1");
        return knowledgeTagMapper.insertBaseTag(baseTag);
    }

    /**
     * 修改基础标签
     * 
     * @param baseTag 基础标签
     * @return 结果
     */
    @Override
    public int updateBaseTag(KnowledgeTag baseTag)
    {
        baseTag.setUpdateTime(DateUtils.getNowDate());
        return knowledgeTagMapper.updateBaseTag(baseTag);
    }

    /**
     * 批量删除基础标签
     * 
     * @param tagIds 需要删除的基础标签主键
     * @return 结果
     */
    @Override
    public int deleteBaseTagByTagIds(Long[] tagIds)
    {
        return knowledgeTagMapper.deleteBaseTagByTagIds(tagIds);
    }

    /**
     * 删除基础标签信息
     * 
     * @param tagId 基础标签主键
     * @return 结果
     */
    @Override
    public int deleteBaseTagByTagId(Long tagId)
    {
        return knowledgeTagMapper.deleteBaseTagByTagId(tagId);
    }

    @Override
    public List<KnowledgeTag> selectBaseTagByTagIds(Long[] tagIds) {
        return knowledgeTagMapper.selectBaseTagByTagIds(tagIds);
    }
}
